package org.example.chatroom.controller;

import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.example.chatroom.common.pojo.request.LoginRequest;
import org.example.chatroom.common.pojo.request.RegisterRequest;
import org.example.chatroom.common.pojo.response.DialogueResponse;
import org.example.chatroom.common.pojo.response.FriendResponse;
import org.example.chatroom.common.pojo.response.LoginResponse;
import org.example.chatroom.common.pojo.response.MessageResponse;
import org.example.chatroom.service.DialogueService;
import org.example.chatroom.service.FriendService;
import org.example.chatroom.service.MessageService;
import org.example.chatroom.service.UserService;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: LIUYANJIAO
 * Date: 2025-06-21
 * Time: 17:29
 */
@RestController
@RequestMapping("/user")
@Slf4j
public class UserController {
    @Resource(name = "userServiceImpl")
    private UserService userService;

    @Resource(name = "friendServiceImpl")
    private FriendService friendService;

    @Resource(name = "dialogueServiceImpl")
    private DialogueService dialogueService;

    @Resource(name = "messageServiceImpl")
    private MessageService messageService;

    @RequestMapping("/register")
    public boolean register(@RequestBody RegisterRequest user){
        return userService.register(user);
    }
    @RequestMapping("/login")
    public LoginResponse login(@RequestBody LoginRequest user){
        return userService.login(user);
    }
    @RequestMapping("/getfriendlist")
    public List<FriendResponse> getfriendlist(Integer userId){
        return friendService.getfriendlist(userId);
    }
    @RequestMapping("/getdialoguelist")
    public List<DialogueResponse> getdialoguelist(Integer userId){
        return dialogueService.getdialoguelist(userId);
    }
    @RequestMapping("/getfrienddialogue")
    public Integer getfrienddialogue (Integer userId,Integer friendId){
        return dialogueService.getfrienddialogue(userId,friendId);
    }
    @RequestMapping("/getmessage")
    public List<MessageResponse> getmessage(Integer dialogueId){
        return messageService.getmessage(dialogueId);
    }

}
